1. Field of Invention
The present invention relates generally to managing defunct processes. More particularly, the present invention relates to modifying processes to reap defunct child processes.
2. Description of the Related Art
Conventional operating systems provide mechanisms for a parent process to create a child process to perform various tasks. For example, in UNIX based operating systems, a parent process associated with a web server program can create a child process to handle an incoming content request. When the child process finishes handling the incoming content request, the operating system performs cleanup on the child process to release resources used by the child process. The operating system then typically notifies the parent that the child process has finished. The operating system, however, can not remove all resources associated with the child process. Exit information associated with the child process remains for consumption by the parent process. During conventional operation, the parent process waits for exit information associated with the child process so that the parent process can acquire exit information associated with the tasks performed by the child. In one example, the parent process can obtain information about whether or the child process terminated normally after completing a task or if the child process was terminated abruptly by the operating system.
In order to acquire exit information, conventional operating systems specify that the parent process be designed to make an explicit call to wait for the exit information associated with the child process. Collecting the exit information associated with the child process is referred to herein as reaping the child process. Generally, a parent process that implements the timely collection of exit information from its child process is referred to herein as a attentive parent process. If the parent process is not interested in the exit information, conventional operating systems specify that the parent process be designed to make an explicit call not to wait for the exit information. Generally, a parent process that signals that it will not collect the exit information of child process is referred to herein as a disinterested parent process. The operating system will not publish exit information to the disinterested parent, and defunct processes will not result.
However, because of various reasons such as faulty design or software bugs, parent processes often fail to make an explicit call to wait or not to wait for the exit information. That is, the parent is neither attentive nor disinterested. Generally, a parent that fails to indicate that it will not collect exit information and fails to collect exit information is referred to herein as a negligent parent process. If the parent process is negligent, the exit information of the child process remains indefinitely. A terminated child process associated with exit information that remains indefinitely is referred to herein as a defunct process or a zombie process.
Conventional operating systems provide no techniques for eliminating the defunct child process without terminating the parent process that created the child process. Defunct child processes negatively impact system operation in a variety of manners. Although defunct child processes use only a small amount of memory, they do consume finite system resources. Faulty software code that results in a single defunct child process may very well lead to many defunct child processes consuming a large amount of resources. In many UNIX based operating systems, processes including defunct child processes are retained in a process table of finite size. A large number of zombie processes can consume many of the process table slots and prevent the creation of new processes. A large number of defunct child processes can also cause a large amount of worry amongst system administrators, as defunct processes may create the impression that the system is operating improperly.
Only very limited solutions exist currently for eliminating defunct processes. One solution is to terminate the parent process that created the defunct child process. In conventional UNIX and UNIX-like environments, every process other than the init process has a parent process. Terminating a parent process which has child processes causes the operating system to modify the parent-child relationship of all child processes of the parent process. Each child's parent relationship is modified such that the init process is made the parent of the child process. The init process is programmed to collect exit information from all of its children as they exit. When the child processes exit, the exit information is collected, and the operating system can completely dispose of the child processes. However, terminating the parent process to reap defunct child processes disrupts system operation, since the parent process may be engaged in useful work. For example, terminating a parent process associated with a web server program to reap a defunct child process can temporarily take an entire web site off-line. Furthermore, if the defunct child process is the result of faulty software code, the defunct processes will likely result again after the restart of the parent process. Another very limited solution is to restart the entire system. However, rebooting the system is an even more disruptive technique for eliminating defunct child processes than terminating the parent process.
Accordingly, improved techniques for managing defunct processes are desirable.